//package com.ruoyi.system.service.activemq;
//
//import cn.hutool.core.collection.IterUtil;
//import cn.hutool.core.date.DateUnit;
//import cn.hutool.core.date.DateUtil;
//import cn.hutool.core.util.CharsetUtil;
//import cn.hutool.core.util.ObjectUtil;
//import cn.hutool.core.util.StrUtil;
//import cn.hutool.crypto.digest.DigestUtil;
//import cn.hutool.crypto.digest.MD5;
//import cn.hutool.http.Header;
//import cn.hutool.http.HttpRequest;
//import cn.hutool.http.webservice.SoapClient;
//import cn.hutool.json.JSONArray;
//import cn.hutool.json.JSONObject;
//import cn.hutool.json.JSONUtil;
//import cn.hutool.json.XML;
//import com.alibaba.fastjson.JSON;
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
//import com.ruoyi.common.utils.SecurityUtils;
//import com.ruoyi.common.utils.sign.Md5Utils;
//import com.ruoyi.system.constant.IpAddressConstant;
//import com.ruoyi.system.domain.ERP.BomInfoErp;
//import com.ruoyi.system.domain.ERP.MaterialDataErp;
//import com.ruoyi.system.domain.HUAWEI.*;
//import com.ruoyi.system.domain.InterfaceLog;
//import com.ruoyi.system.domain.MES.*;
//import com.ruoyi.system.domain.Pull.LineStock;
//import com.ruoyi.system.domain.Pull.MaterialFeed;
//import com.ruoyi.system.domain.Pull.MaterialPlug;
//import com.ruoyi.system.domain.WMS.RptInPackageDTO;
//import com.ruoyi.system.domain.base.DataIsolationLockDTO;
//import com.ruoyi.system.domain.function.ProdOrder;
//import com.ruoyi.system.domain.function.ProdPlan;
//import com.ruoyi.system.enums.MaterialEnum;
//import com.ruoyi.system.enums.MesEnum;
//import com.ruoyi.system.enums.MqEnum;
//import com.ruoyi.system.mapper.*;
//import com.ruoyi.system.mapper.HUAWEI.*;
//import com.ruoyi.system.mapper.MES.*;
//import com.ruoyi.system.mapper.pull.LineStockMapper;
//import com.ruoyi.system.mapper.pull.MaterialFeedMapper;
//import com.ruoyi.system.mapper.pull.MaterialPlugMapper;
//import com.ruoyi.system.service.IBaseSerialNumberService;
//import com.ruoyi.system.service.WMSService;
//import lombok.extern.log4j.Log4j;
//import org.springframework.beans.BeanUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.jms.annotation.JmsListener;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;
//
//import javax.xml.soap.SOAPElement;
//import javax.xml.soap.SOAPException;
//import java.awt.*;
//import java.io.UnsupportedEncodingException;
//import java.util.Date;
//import java.util.List;
//import java.util.Map;
//
///**
// * @description:
// * @author: zhengxiong.jiang
// * @createDate: 2023/2/9
// * @version: 1.0
// */
////我的消费者
//@Service
//public class MyConsumer {
//
//    @Autowired
//    private InterfaceLogMapper interfaceLogMapper;
//    @Autowired
//    private IBaseSerialNumberService iBaseSerialNumberService;
//    @Autowired
//    private ProdOrderMapper prodOrderMapper;
//    @Autowired
//    private ProdPlanMapper prodPlanMapper;
//    @Autowired
//    private KeymatBindMapper keymatBindMapper;
//    @Autowired
//    private MaterialDatasMapper datasMapper;
//    @Autowired
//    private DataCollectionMapper dataCollectionMapper;
//    @Autowired
//    private DataCollectionInfoMapper dataCollectionInfoMapper;
//    @Autowired
//    private MesAralmMapper mesAralmMapper;
//    @Autowired
//    private EmsBarcodeMaterialMapper emsBarcodeMaterialMapper;
//    @Autowired
//    private TBtpMtlCurriculumViateTiMapper tbmapper;
//    @Autowired
//    private EmsBarcodeRelationMapper emsBarcodeRelationMapper;
//    @Autowired
//    private EmsBarcodeAttributeMapper emsBarcodeAttributeMapper;
//    @Autowired
//    private EmsCustomerSnMapper emsCustomerSnMapper;
//    @Autowired
//    private WMSService wmsService;
//    @Autowired
//    private EmsBarcodeShipmentMapper shipmentMapper;
//
//
//    //queue模式的消费者
////    @JmsListener(destination = "${spring.activemq.queue-name}")
////    public void recvMsg_Queue(String message){
////        System.out.println("MOM_to_MES_LineNo接收到：" + message);
////        //接口日志记录
////        InterfaceLog interfaceLog = new InterfaceLog();
////        interfaceLog.setSerialNumber(String.valueOf(new Date().getTime()));
////        interfaceLog.setStartTime(new Date());
////        interfaceLog.setInterfaceDirection("MOM->MES");
////        interfaceLog.setPacketSize("");
////        interfaceLog.setInterfaceType("activeMQ");
////        interfaceLog.setEndTime(new Date());
////        interfaceLog.setInterfaceRequest(message);
////        interfaceLog.setInterfaceResponse("MOM_to_MES_LineNo接收队列成功");
////        long be = DateUtil.between(interfaceLog.getStartTime(), interfaceLog.getEndTime(), DateUnit.SECOND);
////        interfaceLog.setTimeConsuming(String.valueOf(be));
////        interfaceLog.setCreateTime(new Date());
////        interfaceLogMapper.insert(interfaceLog);
////    }
//
//
//    /**
//     * 请求华为父子条码追溯接口 webservice
//     *
//     * @param dto
//     * @param keymatBind
//     */
//    private String sendHuaweitmzs(MaterialDatasDTO dto, KeymatBind keymatBind, String H4, String mtlVendorName) {
//        ProdOrder prodOrder = prodOrderMapper.selectOne(new QueryWrapper<ProdOrder>().eq("order_code", keymatBind.getFPlanNo()));
//
//        String xml = "<![CDATA[<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
//                "<BarcodeRelationSend>\n" +
//                "<Import>\n" +
//                "<PO>" + prodOrder.getTaskTon() + "</PO>\n" +
//                "<VendorID>22827731</VendorID>\n" +
//                "<ORGID>157</ORGID>\n" +
//                "<ItemCode>" + keymatBind.getFProdCodeNo() + "</ItemCode>\n" + // todo mes给
//                "<Barcode>" + keymatBind.getFNumber() + "</Barcode>\n" +
//                "<SonBarcode>" + dto.getFMaterielBarcode() + "</SonBarcode>\n" +
//                "<SonItemCode>" + dto.getFMaterielCode() + "</SonItemCode>\n" +
//                "<Quantity>1</Quantity>\n" +
//                "<Supplier>" + mtlVendorName + "</Supplier>\n" +
//                "<Manufactory></Manufactory>\n" +
//                "<UploadFlag>0</UploadFlag>\n" +
//                "<CheckMessage></CheckMessage>\n" +
//                "<CreatedBy>LD001</CreatedBy>\n" +
//                "<CreatedDate>" + DateUtil.format(dto.getFDate(), "yyyy-MM-dd HH:mm:ss") + "</CreatedDate>\n" +
//                "<UpdatedBy></UpdatedBy>\n" +
//                "<UpdatedDate></UpdatedDate>\n" +
//                "<Segment1>N</Segment1>\n" +
//                "<Segment2>N</Segment2>\n" +
//                "<Segment3>" + prodOrder.getTaskTon() + "</Segment3>\n" +
//                "<Segment4></Segment4>\n" +
//                "<Segment5></Segment5>\n" +
//                "<Segment6></Segment6>\n" +
//                "<Segment7></Segment7>\n" +
//                "<ItemID></ItemID>\n" +
//                "<SonItemID></SonItemID>\n" +
//                "<CheckFlag>0</CheckFlag>\n" +
//                "<EmsTransID>" + H4 + "</EmsTransID>\n" +
//                "<CheckInfo></CheckInfo>\n" +
//                "<Segment8></Segment8>\n" +
//                "<Segment9></Segment9>\n" +
//                "<Segment10>" + dto.getFMaterielCode() + "</Segment10>\n" +
//                "<Segment11>" + keymatBind.getFProdCodeNo() + "</Segment11>\n" + // todo mes给
//                "<Segment12></Segment12>\n" +
//                "<Segment13></Segment13>\n" +
//                "<Segment14>40033</Segment14>\n" +
//                "<Segment15>EMS</Segment15>\n" +
//                "</Import>\n" +
//                "</BarcodeRelationSend>]]>";
//
//
//        SoapClient client = SoapClient.create("http://cmes.huawei.com/hw_manufacture/MidLayer.asmx")
//                .setMethod("Get_Info_Frmbarcode", "http://Auto.huawei.com.cn/")
//                .setParam("sTaskType", "BarcodeRelationSend")
//                .setParam("sImport", xml);
//
//        // 发送请求，参数true表示返回一个格式化后的XML内容
//        // 返回内容为XML字符串，可以配合XmlUtil解析这个响应
//        String send = client.send(true);
//        JSONObject object = XML.toJSONObject(send);
//        Map map3 = JSONUtil.toBean(JSONUtil.toJsonStr(object), Map.class);
//        String res = JSONUtil.toJsonStr(map3);
//        return res;
//
//    }
//
//
//    //topic模式的消费者
//    @JmsListener(destination = "MES_to_MOM", containerFactory = "topicListener")
////    @Transactional(rollbackFor = Exception.class)
//    public void recvMsg_Topic(byte[] message) throws UnsupportedEncodingException {
//        Map maps = (Map) JSON.parse(new String(message, CharsetUtil.UTF_8));
//        System.out.println("topicMES_to_MOM接收到：" + new String(message, CharsetUtil.UTF_8));
//        //你自己的业务接口
//        this.insertCmdResults(maps);
//
//    }
//
//    private void insertCmdResults(Map maps) {
//        String anInterface = (String) maps.get("Interface");
//        //业务逻辑处理
//        if (MqEnum.KEYMAT_BIND.getCode().equals(anInterface)) {//关键物料绑定
//            try {
//                Object body = maps.get("Body");
//                KeymatBindDTO keymatBindDTO = JSONUtil.toBean(JSONUtil.toJsonStr(body), KeymatBindDTO.class);
//                KeymatBind keymatBind = new KeymatBind();
//                BeanUtils.copyProperties(keymatBindDTO, keymatBind);
//                keymatBind.setCreateBy("admin");
//                keymatBind.setCreateTime(new Date());
//                keymatBindMapper.insert(keymatBind);
//                List<MaterialDatasDTO> materialList = keymatBindDTO.getMaterialList();
//                if (IterUtil.isNotEmpty(materialList)) {
//                    materialList.stream().forEach(i -> {
//                        MaterialDatas materialDatas = new MaterialDatas();
//                        BeanUtils.copyProperties(i, materialDatas);
//                        materialDatas.setBindId(keymatBind.getBindId());
//                        materialDatas.setCreateBy("admin");
//                        materialDatas.setCreateTime(new Date());
//                        datasMapper.insert(materialDatas);
//                        //根据物料编码筛选华为物料，进行区分sn，09、psn 逻辑取消
////                            MaterialDataErp materialDataErp = materialDataErpMapper.selectByCode(i.getFMaterielCode());
//                        if (i.getFMaterialType().equals(MaterialEnum.B_INW_BATCH_PSN.getDesc())) {//psn/09
//                            System.out.println("=====================psn消费开始====================");
//                            EmsBarcodeMaterial barcodeMaterial = new EmsBarcodeMaterial();
//                            ProdOrder prodOrder = prodOrderMapper.selectOne(new QueryWrapper<ProdOrder>().eq("order_code", keymatBindDTO.getFPlanNo()));
//                            String taskTon = prodOrder.getTaskTon();
//
//                            barcodeMaterial.setPo(taskTon);
//                            barcodeMaterial.setBarCode(keymatBindDTO.getFNumber());
//                            barcodeMaterial.setItemCode(i.getFMaterielCode());
//                            List<TBtpMtlCurriculumViateTi> list = tbmapper.selectList(new QueryWrapper<TBtpMtlCurriculumViateTi>()
//                                    .eq("item_code", i.getFMaterielCode())
//                                    .eq("barcode", i.getFMaterielBarcode())
//                                    .eq("process_name", "任务令发料")
//                                    .eq("task_no", taskTon)
//                                    .orderByDesc("created_date")
//                            );
//
//
//
//                            if (IterUtil.isNotEmpty(list)) {
//                                barcodeMaterial.setDateCode(list.get(0).getDateCode());
//                                barcodeMaterial.setLotCode(list.get(0).getLotCode());
//                            }
//
//
//                            //通过工单找到对应物料清单的数量
//                            ProdPlan prodPlan = prodPlanMapper.selectOne(new QueryWrapper<ProdPlan>().eq("plan_code", prodOrder.getPlanCode()));
////                                    BomInfoErp bomInfoErp = bomInfoErpMapper.selectOne(new QueryWrapper<BomInfoErp>().eq("order_id", prodPlan.getScddErpId())
////                                            .eq("child_code", i.getFMaterielCode()));
////                                    if(ObjectUtil.isNotNull(bomInfoErp)){
////                                        barcodeMaterial.setQuantity(bomInfoErp.getBaseQuantity());
////                                    }
//                            barcodeMaterial.setQuantity(Double.valueOf(i.getPatchCount()));
//                            barcodeMaterial.setVendorId("22827731");//华为默认
//                            barcodeMaterial.setOrgId(157);//华为默认
//                            barcodeMaterial.setCreatedDate(i.getFDate());
//                            barcodeMaterial.setCreatedBy("马鞍山工厂");
//                            barcodeMaterial.setUploadFlag(0);
//                            String fMaterielBarcode = i.getFMaterielBarcode();
//
//                            //todo 临时逻辑 后续可能会删除此逻辑
//                            if (StrUtil.isNotEmpty(fMaterielBarcode) && fMaterielBarcode.contains("#")) {
//                                String[] split = fMaterielBarcode.split("#");
//                                fMaterielBarcode = split[0];//split[1]date_code split[2]lot_code
//                                barcodeMaterial.setDateCode(split[1]);
//                                barcodeMaterial.setLotCode(split[2]);
//                            }
//                            List<TBtpMtlCurriculumViateTi> list2 = tbmapper.selectList(new QueryWrapper<TBtpMtlCurriculumViateTi>()
//                                    .eq("barcode", i.getFMaterielBarcode())
//                                    .orderByDesc("created_date")
//                            );
//                            if(IterUtil.isNotEmpty(list2)){
//                                barcodeMaterial.setSupplier(list2.get(0).getMtlVendorName());
//                            }
//
//                            barcodeMaterial.setSegment1(fMaterielBarcode);
//                            barcodeMaterial.setSegment2("N");
//                            barcodeMaterial.setSegment4(prodPlan.getTaskTon());
//                            barcodeMaterial.setSegment13(i.getFMaterielBarcode());
//                            barcodeMaterial.setSegment14("40033");
//                            barcodeMaterial.setSegment15("EMS");
//                            barcodeMaterial.setPtionSegment(i.getFMaterielCode().substring(0, 2) + "22827731");
//                            barcodeMaterial.setBarItemCode(keymatBind.getFProdCodeNo());
//                            barcodeMaterial.setEmsTransId(iBaseSerialNumberService.getSerialNumber("H4", 16));
//                            emsBarcodeMaterialMapper.insert(barcodeMaterial);
//                            System.out.println("=====================psn消费结束====================");
//                        } else if (i.getFMaterialType().equals(MaterialEnum.B_INW_BATCH_SN.getDesc())) {//sn
//                            System.out.println("=====================sn消费开始====================");
//                            String h4 = iBaseSerialNumberService.getSerialNumber("H4", 8);
//                            ProdOrder prodOrder = prodOrderMapper.selectOne(new QueryWrapper<ProdOrder>().eq("order_code", keymatBindDTO.getFPlanNo()));
//                            String taskTon = prodOrder.getTaskTon();
//                            String mtlVendorName = "";
//                            List<TBtpMtlCurriculumViateTi> tis = tbmapper.selectList(new QueryWrapper<TBtpMtlCurriculumViateTi>()
//                                    .eq("task_no", taskTon)
//                                    .eq("item_code", i.getFMaterielCode()));
//                            if (IterUtil.isNotEmpty(tis)) {
//                                mtlVendorName = tis.get(0).getMtlVendorName();
//                            }
//
//                            // todo 测试先注释后续放开 进行华为父子条码追溯信息接口发送
//                            String res = this.sendHuaweitmzs(i, keymatBind, h4, mtlVendorName);
//
//                            //本地数据存储
//                            EmsBarcodeRelation emsBarcodeRelation = new EmsBarcodeRelation(i, keymatBind);
//                            emsBarcodeRelation.setPo(taskTon);
//                            emsBarcodeRelation.setSegment3(taskTon);
//                            emsBarcodeRelation.setEmsTransId(h4);
//                            emsBarcodeRelation.setSupplier(mtlVendorName);
//                            // todo 测试先注释后续放开
//                            emsBarcodeRelation.setRes(res);
//                            emsBarcodeRelationMapper.insert(emsBarcodeRelation);
//                            System.out.println("=====================sn消费结束====================");
//                        }
//
//                    });
//                }
//            } catch (Exception e) {
//                //消费异常进行日志记录
//                InterfaceLog interfaceLog = new InterfaceLog();
//                Object body = maps.get("Body");
//                interfaceLog.setInterfaceRequest(JSONUtil.toJsonStr(body));
//                interfaceLog.setSerialNumber(String.valueOf(new Date().getTime()));
//                interfaceLog.setStartTime(new Date());
//                interfaceLog.setInterfaceDirection("MES>MOM");
//                interfaceLog.setPacketSize("");
//                interfaceLog.setInterfaceType("activemq");
//                interfaceLog.setEndTime(new Date());
//                long be = DateUtil.between(interfaceLog.getStartTime(), interfaceLog.getEndTime(), DateUnit.SECOND);
//                interfaceLog.setTimeConsuming(String.valueOf(be));
//                interfaceLog.setCreateTime(new Date());
//                interfaceLog.setInterfaceResponse(e.getMessage());
//                interfaceLog.setInterfaceName("关键物料绑定消费异常");
//                interfaceLogMapper.insert(interfaceLog);
//            }
//
//
//        } else if (MqEnum.DATA_COLLECTION.getCode().equals(anInterface)) {//过站信息
//            try {
//                Object body = maps.get("Body");
//                if (ObjectUtil.isNotNull(body)) {
//                    DataCollection dataCollection = JSONUtil.toBean(JSONUtil.toJsonStr(body), DataCollection.class);
//                    dataCollection.setCreateBy("admin");
//                    dataCollection.setCreateTime(new Date());
//                    dataCollectionMapper.insert(dataCollection);
//                    List<DataCollectionInfo> dataList = dataCollection.getDataList();
//
//                    if (MesEnum.OP010_1.getCode().equals(dataCollection.getFProcessID())) {
//                        for (int i = 0; i < dataList.size(); i++) {
//                            dataList.get(i).setCollectionId(dataCollection.getCollectionId());
//                            dataList.get(i).setCreateBy("admin");
//                            dataList.get(i).setCreateTime(new Date());
//                            dataCollectionInfoMapper.insert(dataList.get(i));
//                        }
//                        String h4 = iBaseSerialNumberService.getSerialNumber("H4", 10);
//                        //todo 测试先注释后续放开 进行华为条码属性回传
//                        String res = this.sendAttribute(dataCollection, h4);
//
//                        //本地数据存储
//                        ProdOrder prodOrder = prodOrderMapper.selectOne(new QueryWrapper<ProdOrder>().eq("order_code", dataCollection.getFPlanNo()));
//                        EmsBarcodeAttribute emsBarcodeAttribute = new EmsBarcodeAttribute(dataCollection);
//                        emsBarcodeAttribute.setEmsTransId(h4);
//                        emsBarcodeAttribute.setPo(prodOrder.getTaskTon());
//                        emsBarcodeAttribute.setSegment5(prodOrder.getTaskTon());
//                        emsBarcodeAttribute.setCreatedBy(dataCollection.getFAccount() + "/" + dataCollection.getFUserName());
//                        //todo 测试先注释后续放开
//                        emsBarcodeAttribute.setRes(res);
//                        emsBarcodeAttributeMapper.insert(emsBarcodeAttribute);
//                    } else if (MesEnum.OP040.getCode().equals(dataCollection.getFProcessID())) {
//
//                        //进行客户条码回传
//                        this.sendCustomerSNAndHWSNRela(dataCollection);
//
//                    }
//                }
//            } catch (Exception e) {
//                //消费异常进行日志记录
//                InterfaceLog interfaceLog = new InterfaceLog();
//                Object body = maps.get("Body");
//                interfaceLog.setInterfaceRequest(JSONUtil.toJsonStr(body));
//                interfaceLog.setSerialNumber(String.valueOf(new Date().getTime()));
//                interfaceLog.setStartTime(new Date());
//                interfaceLog.setInterfaceDirection("MES>MOM");
//                interfaceLog.setPacketSize("");
//                interfaceLog.setInterfaceType("activemq");
//                interfaceLog.setEndTime(new Date());
//                long be = DateUtil.between(interfaceLog.getStartTime(), interfaceLog.getEndTime(), DateUnit.SECOND);
//                interfaceLog.setTimeConsuming(String.valueOf(be));
//                interfaceLog.setCreateTime(new Date());
//                interfaceLog.setInterfaceResponse(e.getMessage());
//                interfaceLog.setInterfaceName("过站信息消费异常");
//                interfaceLogMapper.insert(interfaceLog);
//            }
//
//
//        } else if (MqEnum.MESSAGE_PUSHING.getCode().equals(anInterface)) {//告警信息
//            Object body = maps.get("Body");
//            MesAralmDTO mesAralmDTO = JSONUtil.toBean(JSONUtil.toJsonStr(body), MesAralmDTO.class);
//            MesAralm mesAralm = new MesAralm();
//            BeanUtils.copyProperties(mesAralmDTO, mesAralm);
//            try {
//                mesAralmMapper.insert(mesAralm);
//            } catch (Exception e) {
//                e.printStackTrace();
//            }
//        } else if (MqEnum.DATA_CASENUMBER.getCode().equals(anInterface)) {//包装信息
//            Object body = maps.get("Body");
//            String res = "";
//            try {
//                JSONArray array = JSONUtil.parseArray(JSONUtil.toJsonStr(body));
//                List<RptInPackageDTO> dtoList = JSONUtil.toList(array, RptInPackageDTO.class);
//                res = wmsService.sedPackage(dtoList);
//                //华为出库回传
//                if (IterUtil.isNotEmpty(dtoList)) {
//                    dtoList.stream().forEach(i -> {
//                        List<EmsBarcodeShipment> huaweiTask = i.getHuaweiTask();
//                        if (IterUtil.isNotEmpty(huaweiTask)) {
//                            huaweiTask.stream().forEach(j -> {
//                                shipmentMapper.insert(j);
//                            });
//                        }
//                    });
//                }
//
//            } catch (Exception e) {
//                //消费异常进行日志记录
//                InterfaceLog interfaceLog = new InterfaceLog();
//                interfaceLog.setInterfaceRequest(JSONUtil.toJsonStr(body));
//                interfaceLog.setSerialNumber(String.valueOf(new Date().getTime()));
//                interfaceLog.setStartTime(new Date());
//                interfaceLog.setInterfaceDirection("MOM>MES");
//                interfaceLog.setPacketSize("");
//                interfaceLog.setInterfaceType("activemq");
//                interfaceLog.setEndTime(new Date());
//                long be = DateUtil.between(interfaceLog.getStartTime(), interfaceLog.getEndTime(), DateUnit.SECOND);
//                interfaceLog.setTimeConsuming(String.valueOf(be));
//                interfaceLog.setCreateTime(new Date());
//                interfaceLog.setInterfaceResponse(e.getMessage() + "wms返回结果==》" + res);
//                interfaceLog.setInterfaceName("包装信息消费异常");
//                interfaceLogMapper.insert(interfaceLog);
//            }
//
//        }
//    }
//
//    /**
//     * 客户条码回传
//     *
//     * @param ction
//     */
//    private void sendCustomerSNAndHWSNRela(DataCollection ction) {
//
//        ProdOrder prodOrder = prodOrderMapper.selectOne(new QueryWrapper<ProdOrder>().eq("order_code", ction.getFPlanNo()));
//
//        //回传参数封装
//        CustomerSNAndHWSNRelaDTO dto = new CustomerSNAndHWSNRelaDTO();
//        dto.setPartNo(ction.getFProdCodeNo());
//        dto.setLinkedCustomKeyname("CUSTOMER_SN");
//        dto.setCustomLinkId(iBaseSerialNumberService.getSerialNumber("H4", 5));
//        dto.setTaskNo(prodOrder.getTaskTon());
//        dto.setCreationDate(ction.getFDate());
//        dto.setCreatedBy(ction.getFAccount());
//        dto.setCreatedByName(ction.getFUserName());
//        dto.setSn(ction.getFNumber());
//        dto.setLinkedCustomValue(ction.getAssemblyCode());
//        dto.setSiteId("40033");
//        dto.setSnType("10");
//        if ("02600628".equals(ction.getFProdCodeNo()) || "02600551".equals(ction.getFProdCodeNo()) || "02600552".equals(ction.getFProdCodeNo())) {
//            dto.setLinkType("460");
//        } else if ("02600599".equals(ction.getFProdCodeNo()) || "02600549".equals(ction.getFProdCodeNo())) {
//            dto.setLinkType("465");
//        } else if ("02600626".equals(ction.getFProdCodeNo()) || "02600547".equals(ction.getFProdCodeNo())) {
//            dto.setLinkType("40");
//        } else if ("02600627".equals(ction.getFProdCodeNo()) || "02600507".equals(ction.getFProdCodeNo())) {
//            dto.setLinkType("200");
//        } else if ("02600331".equals(ction.getFProdCodeNo()) || "02600149".equals(ction.getFProdCodeNo())) {
//            dto.setLinkType("470");
//        } else {
//            dto.setLinkType("");
//        }
//
//        // todo 测试先注释后续放开
//        String body = HttpRequest.post(IpAddressConstant.HUAWEI_IP)
//                .header("X-HW-ID", "com.huawei.manufacture.mdip.ah.cqld")
//                .header("X-HW-APPKEY", "cH0Tg+3El7Ss/11iJnH95g==")
//                .header("Content-Type", "application/json")
//                .body(JSONUtil.toJsonStr(dto))
//                .execute().body();
//        Map map = JSONUtil.toBean(body, Map.class);
//        String status = (String) map.get("status");
//        if (!"200".equals(status)) {
//            //客户条码回传失败日志记录
//            InterfaceLog interfaceLog = new InterfaceLog();
//            interfaceLog.setInterfaceRequest(JSONUtil.toJsonStr(dto));
//            interfaceLog.setSerialNumber(String.valueOf(new Date().getTime()));
//            interfaceLog.setStartTime(new Date());
//            interfaceLog.setInterfaceDirection("MES>MOM");
//            interfaceLog.setPacketSize("");
//            interfaceLog.setInterfaceType("activemq");
//            interfaceLog.setEndTime(new Date());
//            long be = DateUtil.between(interfaceLog.getStartTime(), interfaceLog.getEndTime(), DateUnit.SECOND);
//            interfaceLog.setTimeConsuming(String.valueOf(be));
//            interfaceLog.setCreateTime(new Date());
//            interfaceLog.setInterfaceResponse(body);
//            interfaceLog.setInterfaceName("客户条码回传失败");
//            interfaceLogMapper.insert(interfaceLog);
//        }
//
//        //本地数据存储
//        EmsCustomerSn emsCustomerSn = new EmsCustomerSn();
//        BeanUtils.copyProperties(dto, emsCustomerSn);
//        // todo 测试先注释后续放开
//        emsCustomerSn.setRes(body);
//        emsCustomerSnMapper.insert(emsCustomerSn);
//
//    }
//
//    /**
//     * 华为条码属性回传
//     *
//     * @param ction
//     */
//    private String sendAttribute(DataCollection ction, String H4) {
//        ProdOrder prodOrder = prodOrderMapper.selectOne(new QueryWrapper<ProdOrder>().eq("order_code", ction.getFPlanNo()));
//
//        String xml = "<![CDATA[<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
//                "<SubmitBarcodeReleation>\n" +
//                "<Import>\n" +
//                "<EmsTransID>" + H4 + "</EmsTransID>\n" +
//                "<OrganizationID>157</OrganizationID>\n" +
//                "<PO>" + prodOrder.getTaskTon() + "</PO>\n" +
//                "<ItemNumber>" + ction.getFProdCodeNo() + "</ItemNumber>\n" +
//                "<ItemVer></ItemVer>\n" +
//                "<EmsCode>H4</EmsCode>\n" +
//                "<VendorId>22827731</VendorId>\n" +
//                "<Sn>" + ction.getFNumber() + "</Sn>\n" +
//                "<Barcode2d></Barcode2d>\n" +
//                "<Coo>CN</Coo>\n" +
//                "<Updated_by></Updated_by>\n" +
//                "<Updated_date>" + DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss") + "</Updated_date>\n" +
//                "<Created_by>" + ction.getFAccount() + "/" + ction.getFUserName() + "</Created_by>\n" +
//                "<Created_date>" + ction.getFDate() + "</Created_date>\n" +
//                "<Attribute1></Attribute1>\n" +
//                "<Attribute2></Attribute2>\n" +
//                "<Attribute3></Attribute3>\n" +
//                "<Attribute4></Attribute4>\n" +
//                "<Attribute5>" + prodOrder.getTaskTon() + "</Attribute5>\n" +
//                "<Segment1>40033</Segment1>\n" +
//                "<Segment2>1D</Segment2>\n" +
//                "<Segment3></Segment3>\n" +
//                "<Segment4></Segment4>\n" +
//                "<Segment5></Segment5>\n" +
//                "<Type></Type>\n" +
//                "<RoshFlag>Y</RoshFlag>\n" +
//                "</Import>\n" +
//                "</SubmitBarcodeReleation>]]>";
//
//        SoapClient client = SoapClient.create("http://cmes.huawei.com/hw_manufacture/MidLayer.asmx")
//                .setMethod("Get_Info_Frmbarcode", "http://Auto.huawei.com.cn/")
//                .setParam("sTaskType", "SubmitBarcodeReleation")
//                .setParam("sImport", xml);
//
//        // 发送请求，参数true表示返回一个格式化后的XML内容
//        // 返回内容为XML字符串，可以配合XmlUtil解析这个响应
//        String send = client.send(true);
//        JSONObject object = XML.toJSONObject(send);
//        Map map3 = JSONUtil.toBean(JSONUtil.toJsonStr(object), Map.class);
//        String res = JSONUtil.toJsonStr(map3);
////        if(!res.contains("<ErrorCode>0")){
////            //请求失败 进行日志记录
////            InterfaceLog interfaceLog = new InterfaceLog();
////            interfaceLog.setSerialNumber(String.valueOf(new Date().getTime()));
////            interfaceLog.setStartTime(new Date());
////            interfaceLog.setInterfaceDirection("MOM->Huawei");
////            interfaceLog.setPacketSize("");
////            interfaceLog.setInterfaceRequest(JSONUtil.toJsonStr(ction));
////            interfaceLog.setEndTime(new Date());
////            long be = DateUtil.between(interfaceLog.getStartTime(), interfaceLog.getEndTime(), DateUnit.MS);
////            interfaceLog.setTimeConsuming(String.valueOf(be));
////            interfaceLog.setCreateTime(new Date());
////            interfaceLog.setInterfaceType("webservice");
////            interfaceLog.setInterfaceName("条码属性回传失败");
////            interfaceLog.setInterfaceResponse(res);
////            interfaceLogMapper.insert(interfaceLog);
////        }
//
//        return res;
//
//    }
//
//
//}
